import { Decorator_DtoIsNumber_Base } from '@/common/decorators/dtoIsNumber';
import { ApiProperty } from '@nestjs/swagger';
import { IsNotEmpty, IsOptional, IsString } from 'class-validator';
import { PartialType } from '@nestjs/swagger';
import {
  Constant_Enum_Enum_UserClient_Status,
  Constant_Enum_Name_UserClient_Type,
  IConstant_Enum_Type_UserClient_Status,
  IConstant_Enum_Type_UserClient_Type,
} from '@/common/constants/enum';

export class UserClient_Create_Dto {
  @IsString()
  @IsNotEmpty()
  @ApiProperty({ description: '用户名' })
  userName: string;

  @Decorator_DtoIsNumber_Base()
  @IsOptional()
  @ApiProperty({ type: 'bigint', description: '手机号' })
  phone?: number;

  @IsString()
  @IsOptional()
  @ApiProperty({ description: '邮箱' })
  email?: string;

  @IsString()
  @IsOptional()
  @ApiProperty({ description: '密码' })
  password?: string;

  @IsString()
  @IsOptional()
  @ApiProperty({ description: 'openid' })
  openid?: string;

  @IsString()
  @IsOptional()
  @ApiProperty({ description: '用户头像' })
  headimgurl?: string;

  @IsString()
  @IsOptional()
  @ApiProperty({
    description: '状态',
    enum: Constant_Enum_Enum_UserClient_Status,
  })
  statusUser?: IConstant_Enum_Type_UserClient_Status;

  @IsString()
  @IsOptional()
  @ApiProperty({ description: '推广码' })
  distributionCode?: string;
}

export class UserClient_Find_Dto {
  @Decorator_DtoIsNumber_Base()
  @IsOptional()
  id?: number;

  @Decorator_DtoIsNumber_Base()
  @IsOptional()
  size?: number;

  @Decorator_DtoIsNumber_Base()
  @IsOptional()
  page?: number;

  @ApiProperty({ description: '用户名' })
  @IsString()
  @IsOptional()
  userName?: string;

  @ApiProperty({ type: 'bigint', description: '手机号' })
  @Decorator_DtoIsNumber_Base()
  @IsOptional()
  phone?: number;

  @IsString()
  @IsOptional()
  @ApiProperty({ description: '邮箱' })
  email?: string;

  @IsString()
  @IsOptional()
  @ApiProperty({ description: '用户状态', enum: Constant_Enum_Enum_UserClient_Status })
  statusUser?: IConstant_Enum_Type_UserClient_Status;
}

export class UserClient_Update_Dto extends PartialType(UserClient_Create_Dto) {
  @Decorator_DtoIsNumber_Base()
  @IsNotEmpty()
  id: number;
}

export class UserClient_Disabled_Dto {
  @Decorator_DtoIsNumber_Base()
  @IsNotEmpty()
  id: number;
}

export class UserClient_LinkDistrubute_Dto {
  @IsString()
  @IsOptional()
  @ApiProperty({ description: '推广码' })
  distributionCode?: string;
}

export class UserClient_DistrubuteFind_Dto {
  @Decorator_DtoIsNumber_Base()
  @IsOptional()
  size?: number;

  @Decorator_DtoIsNumber_Base()
  @IsOptional()
  page?: number;

  @Decorator_DtoIsNumber_Base()
  @ApiProperty({ description: '邀请者用户Id' })
  @IsOptional()
  inviterId?: number;

  @IsString()
  @IsOptional()
  @ApiProperty({ description: '邀请者用户名称' })
  inviterName?: string;

  @IsString()
  @IsOptional()
  @ApiProperty({ description: '开始时间', type: 'bigint' })
  startTime?: number;

  @IsString()
  @IsOptional()
  @ApiProperty({ description: '结束时间', type: 'bigint' })
  endTime?: number;

  @IsString()
  @IsOptional()
  @ApiProperty({
    description: '推广者类型' + Constant_Enum_Name_UserClient_Type,
  })
  distributionType?: IConstant_Enum_Type_UserClient_Type;
}
